#include "Timestampp.h"

#include <time.h>

Timestampp::Timestampp():microSecondsSinceEpoch_(0){}

Timestampp::Timestampp(int64_t microSecondsSinceEpoch)
:microSecondsSinceEpoch_(microSecondsSinceEpoch){}

Timestampp Timestampp::now(){ 
    return Timestampp(time(NULL));
}

std::string Timestampp::toString() const{
    char buff[128]={0};
    tm *tm_time =  localtime(&microSecondsSinceEpoch_);
    snprintf(buff, 128, "%4d/%02d/%02d %02d:%02d:%02d",
        tm_time->tm_year+1900,
        tm_time->tm_mon,
        tm_time->tm_mday,
        tm_time->tm_hour,
        tm_time->tm_min,
        tm_time->tm_sec);
    return buff;
}

// #include <iostream>
// int main(){
//     std::cout<<Timestampp::now().toString()<<std::endl;
//     return 0;
// }